

import daily.core.Daily
import daily.securety.Account

class DailyController {

    def index() {

    }

    def save(){
        Daily daily = new Daily(params);
        Account account = Account.findByName(session.accountName)
        daily.account = account

        daily.save(flush: true);
        redirect( controller: 'index', action: 'index', model:[dailies:Daily.findAll()])

    }

    def delete(){
        Daily daily = Daily.findById(params.id)

        if (null != daily) {
            daily.delete(flush: true)
        }else{
            render(status: 404, view: '/404', model: [message: '该日报不存在'])
            return
        }


        render (contentType: 'javascript/json'){
            success:true
        }
    }
}
